(function($) {
    $.gDisplay = {
        loadStart: function(target, preloader){
            if (typeof preloader == "undefined")
                preloader = 'default';
            jQuery(target).css('position', 'relative');
            jQuery(target).append('<div class="__preloader"><span class="__'+preloader+'"></span></div>');
        },
        loadStop: function(target){
            jQuery(target +' div.__preloader').remove();
        },
        loadError: function(target,msg){
            this.loadStop(target);
            console.log(msg);
        },
        showAlert: function(json, success, error) {
            if (json.status) {
                this.showSuccess(json.msg, success);
            } else {
                this.showError(json.msg, error);
            }
        },
        showSuccess: function(msg, success) {
            parent.jAlert('success', msg , 'Sucesso', function(r){
                if (r)
                    eval(success);
            });
        },
        showError: function(msg, error) {
            parent.jAlert('error', msg , 'Atenção', function(r){
                if (r)
                    eval(error);
            });
        },
        showConfirm: function(msg, ok, cancel) {
            parent.jConfirm(msg, "Atenção", function(r){
                if (r)
                    eval(ok);
                else
                    eval(cancel);
            });
        }
        ,
        showYN: function(msg, yes, no) {
            parent.jYN(msg, "Atenção", function(r){
                if (r)
                    eval(yes);
                else
                    eval(no);
            });
        }
    }
})(jQuery);


